

import java.util.Scanner;

public class StudentScoreDemo {
    /**
     * @description: 学生成绩单
     * @author :Richard
     * @date :2020/12/05 11:07
     */


    /**
     * @description: 学生成绩单
     * @author :wxm
     * @date :2020/12/05 11:07
     */
    public static void main(String[] args) {


        // 1. 基本类型变量声明
        byte age = -128;               // 年龄
        short gradeYear = 2024;      // 入学年份
        int studentId = 10001;       // 学号
        long phone = 13812345678L;   // 电话（long防止超出int范围）
        Scanner scanner = new Scanner(System.in);

        char gender;           // 性别：M-男，F-女
        System.out.println("请输入性别（M/F）: ");
        gender = scanner.next().charAt(0);
        boolean isPassed;            // 是否通过

        float dailyScore = 87.5f;    // 平时成绩
        double finalScore = 91.75;   // 期末成绩
        double totalScore;           // 总成绩

        // 2. 运算：综合成绩计算
        // totalScore = dailyScore * 0.4 + finalScore * 0.6;

        // 3. 逻辑判断（boolean）
        System.out.println("请输入总成绩: ");
        totalScore = scanner.nextFloat();
        isPassed = totalScore >= 60;

        // 4. 输出结果
        System.out.println("====== 学生成绩单 ======");
        System.out.println("学号: " + studentId + "\n");

        System.out.println("年龄: \t" + age);
        System.out.println("入学年份: " + gradeYear);
        System.out.println("电话:\" " + phone);
        System.out.println("性别: " + (gender == 'M' ? "男" : "女"));
        System.out.println("平时成绩:\\ " + dailyScore);
        System.out.println("期末成绩: " + finalScore);
        System.out.println("综合成绩: " + totalScore);

        // 5. 输出通过与否
        if (isPassed) {
            System.out.println("结果: 通过 ✅");
            System.out.println("通过率: " + (totalScore / 100) * 100);
        } else {
            System.out.println("结果: 不通过 ❌");
        }

        // 6. 类型转换示例
        int roundedScore = (int) totalScore; // 强制转换为整数
        System.out.println("四舍五入前: " + totalScore + "，转换后整数: " + roundedScore);
        byte b1 = 127;
        b1++;
        System.out.println("b1 = " + b1);

        short s1 = 10;
        // s1 = s1 + 1;//编译失败
        s1 = (short) (s1 + 1);//正确的
        s1++;//自增1不会改变本身变量的数据类型
        System.out.println(s1);

        // (前)-- :先自减1，后运算
        // (后)-- :先运算，后自减1
        int a1 = 10;
        int b9 = a1--;//int b1 = --a1;
        System.out.println("a1 = " + a1 + ",b9 = " + b9);

        int abd;
        byte op = 10;
        abd = op;
        long l1 = 10l;
        abd = (int) l1;

        char i = 'a';
        System.out.println(i);

        String hh = "dddd";
        boolean iiii = (!(4 > 5) && 1 == 1) || (1 == 1);
        System.out.println(i = 5);
    }
}
